package org.example;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

public class One extends JPanel {
    private JLabel num;
    private JTextField inputNum;

    public One(MainFrame mainFrame) {
        this.addContent(mainFrame);
    }

    private void addContent(MainFrame mainFrame) {
        this.setLayout(null);
        this.num = new JLabel();
        this.num.setText("请输入激活码:");
        this.inputNum = new JTextField();
        this.inputNum.addKeyListener(new KeyAdapter() {
            @Override
            public void keyTyped(KeyEvent e) {
                super.keyTyped(e);
                if (inputNum.getText().length() == 9){
                    mainFrame.getNext().setEnabled(true);
                }
            }
        });
        this.num.setBounds(20, 20, 100, 30);
        this.inputNum.setBounds(120, 20, 270, 30);

        this.add(this.num);
        this.add(this.inputNum);
    }

    public JLabel getNum() {
        return num;
    }

    public void setNum(JLabel num) {
        this.num = num;
    }

    public JTextField getInputNum() {
        return inputNum;
    }

    public void setInputNum(JTextField inputNum) {
        this.inputNum = inputNum;
    }
}
